home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 1996 April / Software of the Month Club 1996 April.iso / pc / os2 / psutils / src / fixdls~1.pl < prev    next >
Text File  |  1996-02-21  |  2KB  |  55 lines

  1. @PERL@
  2. # fixdlsrps: fix DviLaser/PS document to work with PSUtils
  3. #
  4. # Copyright (C) Angus J. C. Duggan 1991-1995
  5. # See file LICENSE for details.
  6.  
  7. $nesting = 0;
  8. $page = 1;
  9. $infont = 0;
  10.  
  11. @fonts = ();
  12. @body = ();
  13. $header = 1;
  14.  
  15. while (<>) {
  16.    if (/^XP/) {
  17.       $infont++;
  18.       push(@fonts, $_);
  19.       $infont-- if /PXL.*RP/ || /DN?F.*RP/;
  20.    } elsif ($infont) {
  21.       push(@fonts, $_);
  22.       $infont-- if /PXL.*RP/ || /DN?F.*RP/;
  23.    } elsif ((/^%%EndSetup/ || /^%%Page:/) && $header) {
  24.       print @body;
  25.       @body = ("%%EndSetup\n");
  26.       $header = 0;
  27.    } elsif (/^%%EndProlog/ && !$nesting) {
  28.       push(@body,
  29.        "\$DviLaser begin/GlobalMode{}bdef/LocalMode{}bdef/XP{}def/RP{}def",
  30.        "/DoInitialScaling{72.0 Resolution div dup scale}bdef end\n", $_);
  31.    } elsif (/^%%BeginPageSetup/ && !$nesting) {
  32.       push(@body, "%%Page: $page $page\n", $_,
  33.         "Resolution 72 div dup scale Magnification 1000 div dup scale\n",
  34.         "/DocumentInitState where {\n",
  35.         "/DocumentInitState [ matrix currentmatrix currentlinewidth",
  36.         " currentlinecap currentlinejoin currentdash currentgray",
  37.         " currentmiterlimit] cvx put}if\n");
  38.       $page++;
  39.    } elsif (/^%%BeginDocument:/ || /^%%BeginBinary:/ || /^%%BeginFile:/) {
  40.       push(@body, $_);
  41.       $nesting++;
  42.    } elsif (/^%%EndDocument/ || /^%%EndBinary/ || /^%%EndFile/) {
  43.       push(@body, $_);
  44.       $nesting--;
  45.    } elsif (!/^%%PageBoundingBox:/ && !/^%%Page:/) {
  46.       push(@body, $_);
  47.    }
  48. }
  49.  
  50. print @fonts;
  51. print @body;
  52.  
  53. exit 0;
  54. @END@
  55.